<?php
/*
  $Id: article_reviews.php, v1.0 2003/12/04 12:00:00 ra Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

  require('includes/application_top.php');


  function getdowns($current_path = 'download')
  {
  	$down = array();
  	$dir = dir($current_path);
  	while ($file = $dir->read()) {
  		if ( (substr($file,0,1) != '.') && ($file != 'CVS') && ($file != 'Thumbs.db') )  {
  			$file_size = filesize($current_path . '/' . $file) ;
  			if ($showuser) {
  				$user = @posix_getpwuid(fileowner($current_path . '/' . $file));
  				$group = @posix_getgrgid(filegroup($current_path . '/' . $file));
  			} else {
  				$user = $group = array();
  			}
  			$dir2 = $current_path . '/' . $file;
  			if(is_dir($dir2)){
  				$down[] = array(
	  				'name' => $file,
		  			'dir' => $dir2,
		  			'last_modified' => strftime('%Y-%m-%d', filemtime($current_path . '/' . $file))
	  			);
  			} else {

	  			$down[] = array(
	  				'name' => extend_2($file),
		  			'exte' => extend_1($file),
		  			'dir' => $dir2,
		  			'last_modified' => strftime('%Y-%m-%d', filemtime($current_path . '/' . $file)),
		  			'size' => byte_format($file_size)
	  			);
  			}
  		}
  	}
  	usort($down, 'tep_cmp');
  	return $down;
  }
    function tep_cmp($a, $b) {
      return strcmp( $b['last_modified'], $a['last_modified']);
    }


	function extend_1($file_name)
	{
		$retval="";
		$pt=strrpos($file_name, ".");
		if ($pt) $retval=substr($file_name, $pt+1, strlen($file_name) - $pt);
		return ($retval);
	}
	function extend_2($file_name)
	{
		$retval="";
		$pt=strrpos($file_name, ".");
		if ($pt) $retval=substr($file_name, 0, $pt);
		return ($retval);
	}


function byte_format($input, $dec=0)
{
	$prefix_arr = array('bytes', 'Kb', 'Mb', 'Gb', 'Tb');
	$value = round($input, $dec);
	$i=0;
	while ($value>1024)
	{
		$value /= 1024;
		$i++;
	}
	$return_str = round($value, $dec).$prefix_arr[$i];
	return $return_str;
}



?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>

<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.rightMenu_1 {font-size: 12px; font-family: Arial, Helvetica, sans-serif; color: #333333; }
.style19 {	font-size: 11px;
	font-family: Arial, Helvetica, sans-serif;
}
.style5 {	font-size: 12px;
	font-family: Arial, Helvetica, sans-serif;
}
a:link {
	color: #006390;
	text-decoration: none;
}
a:visited {
	text-decoration: none;
	color: #006390;
}
a:hover {
	text-decoration: underline;
	color: #0A76A8;
}
a:active {
	text-decoration: none;
	color: #006390;
}
.style22 {font-family: Arial, Helvetica, sans-serif; color: #003366; font-size: 12px;}
.style23 {color: #1E6388}
.leftMenu1 {
	color: #035481;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-style: normal;
}
.style28 {color: #333333}
.style32 {color: #035481; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-style: normal; font-weight: bold; }
.productName {
	color: #FFFFFF;
	font-family: Georgia, "Times New Roman", Times, serif;
	font-size: 14px;
	font-weight: bold;
}
.Product_item {font-size: 12px; color: #16689A; font-family: Arial, Helvetica, sans-serif; }
.text {font-family: Arial, Helvetica, sans-serif; color: #666666; font-size: 12px;}
.style42 {font-size: 12px; font-family: Arial, Helvetica, sans-serif; color: #CCCCCC; }
.style44 {color: #FFFFFF}
.style46 {color: #003F5E}
.News_title {font-size: 12px;
	font-family: Arial, Helvetica, sans-serif;
	color: #993300;
	font-weight: bold;
}
.text1 {font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	color: #333333;
}
.style39 {font-size: 12px; color: #996600; font-family: Arial, Helvetica, sans-serif; }
.style51 {font-size: 12px; font-family: Arial, Helvetica, sans-serif; color: #333333; font-weight: bold; }
.style55 {font-size: 12px; color: #289ECC; font-family: Arial, Helvetica, sans-serif; }
.Sub-Menu {	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	color: #FFFFFF;
}
.style56 {font-size: 12px; font-family: Arial, Helvetica, sans-serif; color: #2F4773; }
.style25 {color: #292929;
	font-size: 12px;
	font-weight: bold;
	font-family: Arial, Helvetica, sans-serif;
}
.style48 {
	color: #0D769D;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-weight: bold;
}
.style59 {
	color: #333333;
	font-family: Arial, Helvetica, sans-serif;
	font-weight: bold;
	font-size: 18px;
}
.style60 {font-family: Arial, Helvetica, sans-serif}
.style63 {
	font-family: Georgia, "Times New Roman", Times, serif;
	font-size: 16px;
	color: #FFFFFF;
	font-weight: bold;
}
-->
</style>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table width="929" border="0" align="center" cellpadding="0" cellspacing="0">

  <tr>
  <td width="8"><img src="images/space8x8.gif" width="8" height="8" /></td>
    <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="0">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
    </table></td>
    <td width="8"><img src="images/space8x8.gif" width="8" height="8" /></td>
<!-- body_text //-->
    <td width="100%" valign="top">


    <table width="698" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="8"><img src="images/space8x8.gif" width="8" height="8" /></td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td><table width="100%" height="37" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td width="14"><img src="images/2box1.jpg" width="14" height="37" /></td>
                    <td background="images/2box2.jpg" class="style63">Download</td>
                    <td width="14"><img src="images/2box3.jpg" width="14" height="37" /></td>
                  </tr>
                </table></td>
              </tr>
              <tr>
                <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="4" background="images/2box4b.jpg"><img src="images/2box4b.jpg" width="4" height="1" /></td>
                    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td valign="top"><div align="left">
                        <div style="margin:5px 10px;" class="text1"><a href="./">Home</a> / <a href="<?php echo tep_href_link('downloads.php');?>">Download</a>

                        <?php
                        if($_GET['c'] && is_dir(urldecode($_GET['c']))){
                        	echo str_replace('download/',' / ',urldecode($_GET['c']));
                        }
                        ?>

                         </div>
                          <table width="95%" border="0" cellspacing="1" align="center"  cellpadding="1">
                              <tr>
                                <td class="text1" valign="top">

                               <table width="100%" border="0" cellpadding="1" cellspacing="1">

                                <?php


                                if($_GET['c'] && is_dir(urldecode($_GET['c']))){
                                	$docs = getdowns(urldecode($_GET['c']));

                                	echo '<tr bgcolor="#EFEFEF">
          <td width="5%" height="22">&nbsp;</td>
          <td width="60%" ><strong>Name</strong></td>
          <td width="16%"><strong>Size</strong></td>
          <td width="19%"><strong>Update Date</strong></td>

        </tr>';

                                	foreach ($docs as $value) {

	                                	echo '<tr>
          <td  height="20" ><img src="images/icons/'.$value['exte'].'.gif"  /></td>
          <td ><a href="'.$value['dir'].'" target="_blank"><strong>'.$value['name'].'</strong></a></td>
          <td >'.$value['size'].'</td>
          <td >'.$value['last_modified'].'</td>
       </tr>';
	                                }

                                } else {
	                                $docs = getdowns();
	                                foreach ($docs as $value) {
	                                	echo '<tr><td height="22"><b><a href="'.tep_href_link('downloads.php', 'c='.urlencode($value['dir'])).'">'.$value['name']."</a></b></td></tr>";
	                                }
                                }


                                ?>
                                </table>
                                </td>
                              </tr>
                                                  </table>
                        </div></td>
                      </tr>

                    </table></td>
                    <td width="4" background="images/2box4bb.jpg"><img src="images/2box4bb.jpg" width="4" height="1" /></td>
                  </tr>
                </table></td>
              </tr>
              <tr>
                <td><table width="697" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="14" height="16"><img src="images/2box5.jpg" width="14" height="16" /></td>
                    <td background="images/2box6.jpg" width="669">  </td>
                    <td width="14" height="16"><img src="images/2box7.jpg" width="14" height="16" /></td>
                  </tr>
                </table></td>
              </tr>
            </table>
              </td>
          </tr>
        </table>


    </td>
<!-- body_text_eof //-->
    <td width="8"><img src="images/space8x8.gif" width="8" height="8" /></td>
  </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>